export

ifeq (${MAKELEVEL},0)
BUILDDIR:=.
OPENSSLDIR:=$(OPENSSLDIR)
VPATH:=$(VPATH):$(OPENSSLDIR):.
COMPILIER:=omp
OPENSSLDIR:=/home/fedora/HPC/stage1/xlc/openssl-0.9.8g
endif


all: debug

release debug clean:
	${MAKE} TARGETTYPE=$@ -f ./Makefile.lib $@

test_shared:
	$(MAKE) TARGETTYPE=debug -f ./Makefile.shared test

test_prog:
	$(MAKE) TARGETTYPE=debug -f ./Makefile.prog test

postrelease postdebug: ;
.PHONY: release debug all test

SSCCFLAGS:=-qstrict

mytest:
	@echo "Building single executable (testprog_static)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -L. -qsmp  -o ./testprog_static testprog.c hellolib.c
# [fedora@fc7 src]$ scp ./testprog2 ps3:/tmp/
	@echo "Building shared object (libhellolib.so) with single function (no -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -qmkshrobj  -o ./libhellolib.so ./hellolib.c
	@echo "Building shared object (libhellolib_smp.so) with single function (with -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -qmkshrobj  -o ./libhellolib_smp.so ./hellolib.c
	@echo "Building executable which static linkage, dynamic load of hellolib (no -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -L. -o ./testprog_dynamic testprog.c -lhellolib
	@echo "Building executable which static linkage, dynamic load of hellolib (with -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -L. -qsmp  -o ./testprog_smp_dynamic testprog.c -lhellolib
	@echo "Building executable which static linkage, dynamic load of hellolib_smp (no -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -L. -qsmp  -o ./testprog_dynamic_smp testprog.c -lhellolib_smp
	@echo "Building executable which static linkage, dynamic load of hellolib_smp (with -qsmp)"
	PATH=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin cbexlc $(SSCCFLAGS) -I/home/fedora/HPC/stage1/xlc/openssl-0.9.8g/include -qarch=cell -L. -qsmp  -o ./testprog_smp_dynamic_smp testprog.c -lhellolib_smp

mytestcopy:
	scp ./libhellolib*.so ps3:/tmp/
	scp ./testprog_* ps3:/tmp/

mytestrun:
	@echo "Running _static"
	-ssh ps3 "cd /tmp && LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:. ./testprog_static"
	@echo "Running _dynamic"
	-ssh ps3 "cd /tmp && LD_LIBRARY_PATH=$$(LD_LIBRARY_PATH):. ./testprog_dynamic"
	@echo "Running _dynamic_smp"
	-ssh ps3 "cd /tmp && LD_LIBRARY_PATH=$$(LD_LIBRARY_PATH):. ./testprog_dynamic_smp"
	@echo "Running _smp_dynamic_smp"
	-ssh ps3 "cd /tmp && LD_LIBRARY_PATH=$$(LD_LIBRARY_PATH):. ./testprog_smp_dynamic_smp"


